package com.lvyq.controller;

import com.lvyq.model.apiinfo.ApiInfo;
import com.lvyq.model.farm.FarmGrade;
import com.lvyq.model.farm.Fertilizer;
import com.lvyq.model.goods.GoodsRelation;
import com.lvyq.model.pasture.PastureGoodsInfo;
import com.lvyq.model.pasture.PastureShedNest;
import com.lvyq.model.shop.ShopGoods;
import com.lvyq.model.user.JueWei;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

/**
 * @program: weg
 * @description: 设置
 * @author: lvyq
 * @create: 2023-03-07 21:43
 **/
@RestController
@RequestMapping("/setting")
public class SettingController {

    @Resource
    private MongoTemplate mongoTemplate;

    @PostMapping("/saveJueWei")
    public void  savaJueWei(@RequestBody JueWei data){
        mongoTemplate.save(data);
    }

    /** 
    * @Description: 商店物品保存
    * @params:  * @param goods
    * @return: 
    * @Author: lvyq
    * @Date: 2023/3/24 14:45
    */
    @PostMapping("/saveGoods")
    public void saveGoods(@RequestBody ShopGoods goods){
        mongoTemplate.save(goods);
    }


    /**
     * @Description: 农场物品关联
     * @params:  * @param goods
     * @return:
     * @Author: lvyq
     * @Date: 2023/3/24 14:45
     */
    @PostMapping("/saveGoodsRelation")
    public void saveGoodsRelation(@RequestBody GoodsRelation relation){
        mongoTemplate.save(relation);
    }

    /** 
    * @Description: 保存庄园等级
    * @params:  * @param relation
    * @return: 
    * @Author: lvyq
    * @Date: 2023/4/9 13:35
    */
    @PostMapping("/saveFarmGrade")
    public void saveFarmGrade(@RequestBody FarmGrade farmGrade){
            mongoTemplate.save(farmGrade);
    }

    /**
     * @Description: 施肥
     * @params:  * @param relation
     * @return:
     * @Author: lvyq
     * @Date: 2023/4/9 13:35
     */
    @PostMapping("/saveFertilizer")
    public void saveFertilizer(@RequestBody Fertilizer fertilizer){
        mongoTemplate.save(fertilizer);
    }

    /**
    * @Description: API维护
     * @param apiInfo
    * @return:
    * @Author: lvyq
    * @Date: 2023/5/4 11:25
    */
    @PostMapping("/saveApiInfo")
    public void saveApiInfo(ApiInfo apiInfo){
        mongoTemplate.save(apiInfo);
    }




    /**
     * 牧场动物属性
     * @param pastureGoodsInfo
     */
    @PostMapping("/savePastureGoodsInfo")
    public void savePastureGoodsInfo(@RequestBody PastureGoodsInfo pastureGoodsInfo){
        mongoTemplate.save(pastureGoodsInfo);
        ShopGoods shopGoods = new ShopGoods();
        shopGoods.setGoodsName(pastureGoodsInfo.getGoodsName());
        shopGoods.setGoodsLevel(pastureGoodsInfo.getLevel());
        shopGoods.setGoodsType(3);
        shopGoods.setCurrency(1);
        shopGoods.setSellingPrice(pastureGoodsInfo.getBuyingRate());
        shopGoods.setPrice(pastureGoodsInfo.getBuyingRate());
        shopGoods.setShopType(3);
        mongoTemplate.save(shopGoods);
    }

    /**
     * 牧场窝棚等级关系表维护
     * @param pastureShedNest
     */
    @PostMapping("/savePastureShedNest")
    public void  savePastureShedNest(@RequestBody PastureShedNest pastureShedNest){
        mongoTemplate.save(pastureShedNest);
    }
}
